﻿using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SmartCity.Shared;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;

namespace CommonManagement
{
    /// <summary>
    /// 意见反馈控制器
    /// </summary>
    [RemoteService]
    [Area("commonManagement")]
    [Route("api/commonManagement/feedbacks")]
    public class FeedbackController : AbpController, IFeedbackAppService
    {
        private readonly IFeedbackAppService _feedbackAppService;

        public FeedbackController(
            IFeedbackAppService feedbackAppService)
        {
            _feedbackAppService = feedbackAppService;
        }

        // 1.4.1 新增意见反馈
        [Authorize]
        [HttpPost]
        [Route("")]
        public Task<ActionResponse> CreateAsync(CreateFeedbackDto input)
        {
            return _feedbackAppService.CreateAsync(input);
        }

        // 1.4.2 查询意见反馈列表
        [Authorize]
        [HttpGet]
        [Route("list")]
        public Task<ListResponse<FeedbackDto>> PagedListAsync(
            PagedListRequest request,
            string title)
        {
            return _feedbackAppService.PagedListAsync(request, title);
        }

        // 1.4.3 获取意见反馈详情
        [Authorize]
        [HttpGet]
        [Route("{id:int}")]
        public Task<ResultResponse<FeedbackDto>> GetAsync(int id)
        {
            return _feedbackAppService.GetAsync(id);
        }
    }
}